package com.gitee.huanminabc.utils_test.dal.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gitee.huanminabc.utils_test.dal.dao.ApplicationDaoService;
import com.gitee.huanminabc.utils_test.dal.mapper.ApplicationMapper;
import com.gitee.huanminabc.utils_test.entity.ApplicationEntity;
import com.gitee.huanminabc.dynamicdb.aop.DBSwitch;
import org.springframework.stereotype.Service;

@Service
@DBSwitch("resource")
public class  ApplicationDaoServiceImpl extends ServiceImpl<ApplicationMapper, ApplicationEntity> implements ApplicationDaoService {


    @Override
    public boolean hasPermission(String account, String appId, String appSecret) {
        LambdaQueryWrapper<ApplicationEntity> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ApplicationEntity::getAppId,appId);
        wrapper.eq(ApplicationEntity::getAppSecret,appSecret);
        wrapper.eq(ApplicationEntity::getAccount,account);
        wrapper.eq(ApplicationEntity::getDelFlag,0);
        return this.count(wrapper)>0;
    }
}
